<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateWaimaiAnalysisTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('waimai_analysis', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('shopCode')->default(0)->comment('店铺code');
            $table->tinyInteger('sourceType')->default(0)->comment('3美团 4饿了么');
            $table->string('shopName', 32)->default('')->comment('店铺名称');
            $table->string('categoryName', 24)->default('')->comment('分类名称');
            $table->tinyInteger('categoryType')->default(0)->comment('分类类型 0默认 1炸串炸鸡');
            $table->smallInteger('orderNum')->default(0)->comment('订单数');
            $table->decimal('lng', 9, 6)->default(0)->comment('lng 经度');
            $table->decimal('lat', 9, 6)->default(0)->comment('lat 纬度');
            $table->string('addressPrefix', 64)->default('')->comment('省-市-区');
            $table->unsignedInteger('provinceCode')->default(0)->comment('省');
            $table->unsignedInteger('cityCode')->default(0)->comment('市');
            $table->unsignedInteger('areaCode')->default(0)->comment('区');
            $table->comment = '外卖分析数据表';

            $table->index('shopCode', 'idx_shopCode');
            $table->index('categoryType', 'idx_categoryType');
            $table->index(['lng', 'lat'], 'idx_lng_lat');
            $table->index(['provinceCode', 'cityCode', 'areaCode'], 'idx_address_code');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('waimai_analysis');
    }
}
